package acwing._2LanQiao._9DP;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._2LanQiao._9DP
 * @File : Q1222.java
 * @Author : WangRuoyu
 * @Date : 2023/3/23 16:45
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q1222 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[][] f = new int[line.length()][line.length()];
        for (int len = 1; len <= line.length(); ++len) {
            for (int l = 0; l < line.length() - len + 1; ++l) {
                int r = l + len - 1;
                if (r == l) f[l][r] = 1;
                else {
                    if (line.charAt(l) == line.charAt(r)) f[l][r] = f[l + 1][r - 1] + 2;
                    if (f[l + 1][r] > f[l][r]) f[l][r] = f[l + 1][r];
                    if (f[l][r - 1] > f[l][r]) f[l][r] = f[l][r - 1];
                }
            }
        }
        System.out.println(line.length() - f[0][line.length() - 1]);
    }
}
